<?php

include 'WeixinPay.php';

$openid=$_GET['openid'];
//echo "openid：".$openid;
//echo "<br>";

$appid='---------------------------'; //小程序 appid
//$openid= $_POST['id']; //微信用户的openid
$mch_id='---------------------------'; //微信支付商户支付号
$key='-------------------------------'; //Api 密钥
$out_trade_no = date('YmdHis').rand(100,999);
$total_fee = $_GET['fee'];
$add_time = time();
$body = "支付测试";
//echo "total_fee：".$total_fee;
//echo "<br>";
/*if(empty($total_fee)) //押金
{
    $body = "充值押金";
    $total_fee = floatval(99*100);
}
 else {
     $body = "支付测试";
     $total_fee = floatval($total_fee*100);
 }*/
 
 
$query = "INSERT INTO pay_order (open_id,order_no,order_money) VALUE ('$openid','$out_trade_no','$total_fee')";
@mysql_query($query);
 
$weixinpay = new WeixinPay($appid,$openid,$mch_id,$key,$out_trade_no,$body,$total_fee);
$return=$weixinpay->pay();

echo json_encode($return);